package com.erp.erp_ui.Cost.Controller;

import com.erp.erp_entitys.Cost.req.InsertPlanInStoreProductInfoReq;
import com.erp.erp_entitys.Cost.vo.QueryCostApportionmenVO;
import com.erp.erp_ui.Cost.Service.CostApportionmentAllService;
import com.erp.utils.R;
import com.erp.utils.ResultStatusEnum;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author zjk
 * @version 1.0
 * @description
 * @date 2021-06-14 4:22
 */
@Controller
@RequestMapping("costApportionment")
public class CostApportionmentController {
    /**
     * 日志
     */
    private static final Logger log= LoggerFactory.getLogger(CostApportionmentController.class);



    private final CostApportionmentAllService costApportionmentAllService;

    public CostApportionmentController(CostApportionmentAllService costApportionmentAllService) {
        this.costApportionmentAllService = costApportionmentAllService;
    }

    /**
     * 保存入库费用分摊信息
     * @param req
     * @return
     */
    @RequestMapping("addCostApportionment")
    @ResponseBody
    public R addCostApportionment(@RequestBody List<InsertPlanInStoreProductInfoReq> req){
        try {
            log.info("保存入库费用分摊信息=req:"+req.toString());
            R r=costApportionmentAllService.add(req);

            return r;
        } catch (Exception e) {
            log.error("费用->保存入库费用分摊信息异常=req:"+req.toString());
            return R.buildError(ResultStatusEnum.SYSTEM_ERROR);
        }
    }

}
